//    Copyright (C) Kherty.  All rights reserved.
using System.IO;
using OpenLS.Spreadsheet.Expressions;

namespace OpenLS.Spreadsheet.Formats.Biff.Tokens
{
    internal class BooleanToken : FormulaToken
    {
        public BooleanToken()
        {
            
        }

        public BooleanToken(bool value)
        {
            _value = value;
        }

        private bool _value;

        public override ushort GetLength(FormulaReadContextType formulaReadContextType)
        {
            return 1;
        }
        public override FormulaTokenId TokenId
        {
            get { return FormulaTokenId.Bool; }
        }

        internal override void ReadContent(FormulaReadContext context)
        {
            _value = context.ReadBoolean();
        }
        public override void WriteContent(FormulaWriteContext context)
        {
            context.Writer.Write(_value);
        }

        internal override Expression GetExpression(FormulaEvaluationContext context)
        {
            return new BooleanConstantExpression(_value);
        }
    }
}